package com.company.json;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.util.HashMap;
import java.util.Iterator;

/**
 * Created by v on 17-4-22.
 */
public class RemoveRepeat {

    /**
     * 除去这个节点集里面，每个节点文本重复的那些tag
     * @param elements
     */
    public static void RemoveRepeat(Elements elements){
        HashMap<String,Elements> map=new HashMap<>();


    }
    //递归函数
    public static void Mapping(Elements elements,HashMap<String,Elements> map){
        if(elements==null){
            return;
        }

        Iterator<Element> iterator=elements.iterator();

        while (iterator.hasNext()){
            Element element=iterator.next();
            if(map.containsKey(element.ownText())){
                map.get(element.ownText()).add(element);
            }else {
                Elements eles=new Elements();
                eles.add(element);
                map.put(element.ownText(),eles);
            }
        }


    }
}
